/**
 *
 */
package cn.kmsoft.jssc.config;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 *
 * @author wangqiang
 * @date 2022年11月
 */
@Configuration
@EnableSwagger2
public class SwaggerCfg {
    //private static final Log log = LogFactory.getLog(SwaggerCfg.class);
    private static final Logger logger = LoggerFactory.getLogger(SwaggerCfg.class);


    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                //.select().apis(RequestHandlerSelectors.any())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 只过滤包含有ApiOperation注解的方法
                .paths(PathSelectors.any()) // 对所有的路径进行监控
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("技术审查服务 RESTful APIs")
                .description("技术审查服务 RESTful 风格的接口文档，基于spatialboot底层空间叠加分析能力搭建的面向规划和自然资源领域的业务分析服务。")
                .termsOfServiceUrl("http://localhost:8095/jssc/api")
                .version("1.0.0")
                .build();
    }
}
